package com.example.canteen.converter;

import com.example.canteen.dao.Dish;
import com.example.canteen.dao.Order;
import com.example.canteen.dao.SetMeal;
import com.example.canteen.dto.OrderDTO;

import java.util.stream.Collectors;

public class OrderConverter {
    public static OrderDTO convertOrder(Order order) {
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setId(order.getId());
        orderDTO.setDate(order.getDate());
        orderDTO.setPrivateRoomDTO(PrivateRoomConverter.convertPrivateRoom(order.getPrivateRoom()));
        orderDTO.setName(order.getName());
        if (order.getPrivateRoom() != null) {
            orderDTO.setPrivateRoomName(order.getPrivateRoom().getName());
        }
        return orderDTO;
    }

    public static Order convertOrder(OrderDTO orderDTO) {
        Order order = new Order();
        order.setId(orderDTO.getId());
        order.setDate(orderDTO.getDate());
        if (orderDTO.getPrivateRoomDTO() != null) {
            order.setPrivateRoom(PrivateRoomConverter.convertPrivateRoom(orderDTO.getPrivateRoomDTO()));
        }
        order.setName(orderDTO.getName());
        return order;
    }
}
